home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / intro.dxr / 00041_MIDI dialog handlers - pushbutton.ls < prev    next >
Encoding:
Text File  |  1996-02-15  |  5.6 KB  |  202 lines

  1. global gCPU, CHIMEnotes, gObjects, gAnimationObjects, myMidiDevice, outDevName, OutDevNumsList, hotCursorlist, gLimitPreLoad
  2.  
  3. on pushButton2 Action, holdDown
  4.   set theClickOn to the clickOn
  5.   cursor([the number of cast "Pointcursor", the number of cast "Pointcursor.mask"])
  6.   set thisButton to the castNum of sprite theClickOn
  7.   updateStage()
  8.   repeat while the stillDown
  9.     if rollOver(theClickOn) then
  10.       set the castNum of sprite theClickOn to the number of cast thisButton + 1
  11.       updateStage()
  12.       next repeat
  13.     end if
  14.     set the castNum of sprite theClickOn to thisButton
  15.     updateStage()
  16.   end repeat
  17.   if voidp(holdDown) then
  18.     set the castNum of sprite theClickOn to thisButton
  19.   end if
  20.   updateStage()
  21.   if rollOver(theClickOn) then
  22.     doAction(Action, thisButton, holdDown)
  23.   end if
  24. end
  25.  
  26. on doAction Action, thisButton, holdDown
  27.   if not voidp(holdDown) then
  28.     set Action to string(Action && thisButton)
  29.   end if
  30.   do(string(Action))
  31. end
  32.  
  33. on doCheckClick
  34.   if the hilite of cast "Turbo checkBox" then
  35.     set gLimitPreLoad to 1
  36.   else
  37.     set gLimitPreLoad to 0
  38.   end if
  39. end
  40.  
  41. on playNotes thisButton
  42.   if objectp(windowsMIDIXObj) then
  43.     cursor([the number of cast "NullCursor", the number of cast "NullCursor.mask"])
  44.     set gObjects to [#CHIME: [#Children: [#CHIMEmonitor, #Flake1, #Flake2, #Flake3, #Flake4], #ChildStates: [1, 1, 1, 1], #DisplayState: #false, #Monitor: #CHIMEmonitor, #PlugInMixer: #true, #RefName: #CHIME, #solved: 0, #SpriteNum: 50, #State: #nonChaotic, #type: #Parent]]
  45.     set gAnimationObjects to [:]
  46.     set lastNoteTime to the ticks - 10
  47.     set INTRument to #CHIME
  48.     set stopTime to the timer + (2 * 60)
  49.     repeat while the timer < stopTime
  50.       if the ticks < (lastNoteTime + 5) then
  51.         next repeat
  52.       end if
  53.       set note to getRandomNote(DRUM, 3, 8)
  54.       if note > 0 then
  55.         if note > 127 then
  56.           set note to note / 2
  57.         end if
  58.         noteOn(INTRument, note, 127)
  59.         set duration to the ticks + random(30)
  60.         repeat while the ticks < duration
  61.           CursorandUpdate()
  62.         end repeat
  63.         noteOff(INTRument, note)
  64.         set lastNoteTime to the ticks
  65.       end if
  66.     end repeat
  67.   end if
  68.   set the castNum of sprite 2 to thisButton
  69. end
  70.  
  71. on setMidiConfig
  72.   if voidp(myMidiDevice) then
  73.     set myMidiDevice to 1
  74.   end if
  75.   if not myMidiDevice > 0 then
  76.     set myMidiDevice to 1
  77.   end if
  78.   settingMidiDrv(myMidiDevice)
  79. end
  80.  
  81. on setTurboConfig
  82.   if voidp(gLimitPreLoad) then
  83.     set the hilite of cast "Turbo checkBox" to 1
  84.     set gLimitPreLoad to 0
  85.   else
  86.     set the hilite of cast "Turbo checkBox" to not gLimitPreLoad
  87.   end if
  88. end
  89.  
  90. on settingMidiDrv direction
  91.   global thisSetting
  92.   if voidp(thisSetting) then
  93.     set thisSetting to 0
  94.   end if
  95.   set minSetting to 1
  96.   if not voidp(OutDevNumsList) then
  97.     set maxSetting to min(count(OutDevNumsList), 9)
  98.   end if
  99.   if maxSetting = 0 then
  100.     set the castNum of sprite 3 to the number of cast "miditestPrev.dim"
  101.     set the castNum of sprite 4 to the number of cast "miditestnext.dim"
  102.     set the text of field "miditext" to "No Available MIDI Device Drivers."
  103.     updateStage()
  104.     exit
  105.   end if
  106.   if objectp(windowsMIDIXObj) then
  107.     if windowsMIDIXObj(mCloseOut) then
  108.       alert("Error closing device - Unable to open this device")
  109.     end if
  110.   end if
  111.   set thisSetting to thisSetting + direction
  112.   if thisSetting <= minSetting then
  113.     set thisSetting to minSetting
  114.     set the castNum of sprite 3 to the number of cast "miditestPrev.dim"
  115.   else
  116.     if thisSetting >= maxSetting then
  117.       set thisSetting to maxSetting
  118.       set the castNum of sprite 4 to the number of cast "miditestnext.dim"
  119.     else
  120.       set the castNum of sprite 3 to the number of cast "miditestPrev.up"
  121.       set the castNum of sprite 4 to the number of cast "miditestnext.up"
  122.     end if
  123.   end if
  124.   set myMidiDevice to thisSetting
  125.   if objectp(windowsMIDIXObj) then
  126.     set outDevID to getAt(OutDevNumsList, myMidiDevice)
  127.     set outDevName to windowsMIDIXObj(mGetDevName, "OUT", outDevID)
  128.     if windowsMIDIXObj(mOpenOut, outDevID, 1024) then
  129.       if (thisSetting = minSetting) or (thisSetting = maxSetting) then
  130.         settingMidiDrv(opposite(direction))
  131.       else
  132.         settingMidiDrv(direction)
  133.       end if
  134.     end if
  135.   end if
  136.   if objectp(windowsMIDIXObj) then
  137.     set the text of field "miditext" to "#" & myMidiDevice && "-" && outDevName
  138.   else
  139.     set the text of field "miditext" to "No Available MIDI Device Drivers."
  140.   end if
  141.   updateStage()
  142. end
  143.  
  144. on opposite direction
  145.   if direction then
  146.     set direction to 0
  147.   else
  148.     set direction to 1
  149.   end if
  150.   return direction
  151. end
  152.  
  153. on saveMidiSettings
  154.   global saveResult
  155.   set saveResult to savePrefData()
  156. end
  157.  
  158. on continueGame
  159.   cursor([the number of cast "NullCursor", the number of cast "NullCursor.mask"])
  160.   go("loadgameNow")
  161. end
  162.  
  163. on saveMidiAndContinueGame
  164.   puppetbuttons(0)
  165.   saveMidiSettings()
  166.   continueGame()
  167. end
  168.  
  169. on CheckRollOver
  170.   if getOne(hotCursorlist, rollTest()) > 0 then
  171.     cursor([the number of cast "Pointcursor", the number of cast "Pointcursor.mask"])
  172.     updateStage()
  173.   else
  174.     cursor([the number of cast "NullCursor", the number of cast "NullCursor.mask"])
  175.     updateStage()
  176.   end if
  177. end
  178.  
  179. on rollTest
  180.   repeat with thisSprite in hotCursorlist
  181.     if rollOver(thisSprite) then
  182.       if the castNum of sprite thisSprite > 0 then
  183.         return thisSprite
  184.         next repeat
  185.       end if
  186.       return 48
  187.     end if
  188.   end repeat
  189. end
  190.  
  191. on initconfigFrame
  192.   global hotCursorlist
  193.   set hotCursorlist to [2, 3, 4, 5, 6]
  194. end
  195.  
  196. on puppetbuttons flag
  197.   global hotCursorlist
  198.   repeat with thisSprite in hotCursorlist
  199.     puppetSprite(thisSprite, flag)
  200.   end repeat
  201. end
  202.